<?php
	include("scripts/connection.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<meta http-equiv="Content-Script-Type" content="text/javascript" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen, projection, tv" />
<!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/style-ie.css" media="screen, projection, tv" /><![endif]-->
<link rel="stylesheet" href="css/style-print.css" type="text/css" media="print" />

<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript">
function getInfo(id1, id2)
{
	var e1 = document.getElementById(id1);
	var e2 = document.getElementById(id2);
	
	e2.innerHTML="";

	if(e1.value == "engineering")
	{
		var optionArray = [];
	<?php

		$lessons = mysql_query("SELECT * FROM faculty_lessons WHERE faculty='ENGINEERING'");
		while($l = mysql_fetch_array($lessons))
		{
	?>
			optionArray.push("<?php echo $l['id_name']."|".$l['lesson']; ?>");
	<?php
		}
	?>	
	}
	else if(e1.value == "economic")
	{
		var optionArray = [];
	<?php
		$lessons = mysql_query("SELECT * FROM faculty_lessons WHERE faculty='ECONOMICS'");
		while($l = mysql_fetch_array($lessons))
		{
	?>
			optionArray.push("<?php echo $l['id_name']."|".$l['lesson']; ?>");
	<?php
		}
	?>	
	}
	else if(e1.value == "law")
	{
		var optionArray = [];
	<?php
		$lessons = mysql_query("SELECT * FROM faculty_lessons WHERE faculty='LAW'");
		while($l = mysql_fetch_array($lessons))
		{
	?>
			optionArray.push("<?php echo $l['id_name']."|".$l['lesson']; ?>");
	<?php
		}
	?>
	}
	else if(e1.value == "philology")
	{
		var optionArray = [];
	<?php
		$lessons = mysql_query("SELECT * FROM faculty_lessons WHERE faculty='PHILOLOGY'");
		while($l = mysql_fetch_array($lessons))
		{
	?>
			optionArray.push("<?php echo $l['id_name']."|".$l['lesson']; ?>");
	<?php
		}
	?>
	}
	
	for(var option in optionArray)
	{
		var pair = optionArray[option].split('|');
		var newOption = document.createElement("option");
		newOption.value = pair[0];
		newOption.innerHTML = pair[1];
		e2.options.add(newOption);
	}
}
</script>

<title>SDU</title>
</head>

<body>

<div id="wrapper">
		<?php
			include("header.php");
		?>
<div id="content-box-left">
	<div id="content-box-left-in">
		<div class="paging" title="" align='center'>
				<div class="box">
					<div id="box-in">
						<div class="article">
							<h2 align='center'>REGISTRATION</h2><br>	
								<form action="scripts/s_r.php" method="post"><br>
									<table align="center" cellpadding="10" cellspacing="10" >
										<tr>
											<td>faculty :</td>
											<td>
												<select id="faculty" name="faculty" onchange="getInfo(this.id, 'lessons')">
												<option value="">Select</option>
												<option value="engineering">ENGINEERING</option>
												<option value="economic">ECONOMIC</option>
												<option value="law">LAW</option>
												<option value="philology">PHILOLOGY</option>
												</select>
											</td>
										</tr>
										<tr>
											<td>less name :</td>
											<td>
												<select id="lessons" name="lesson"></select>
											</td>
										</tr>						  
										<tr>
											<td>tick of :</td>
											<td><input type="radio" name="tick" value="retake">retake</td>
										</tr>
										<tr>	
											<td>
											</td>
											<td><input type="radio" name="tick" value="upgrade">upgrade</td>
                                        </tr>
										<tr>
											<td>
												Teacher :
											</td>
											<td>
												<select name="teacher">
												<option value="">Select</option>
												<?php
													$result = mysql_query("SELECT * FROM user WHERE user_status=3");
													while($row = mysql_fetch_array($result))
													{
														echo "<option value=".$row['user_id'].">".$row['user_name']." ".$row['user_surname']."</option>";
													}
													if($_SESSION['alert'])
													{
														echo "<script language=javascript>alert('Successful');</script>";
														unset($_SESSION['alert']);
													}
												?>
												</select>
											</td>
										</tr>
										<tr>
											<td colspan="2" align='center'><input type="submit" value="OK"/></td>
										</tr>										
									</table>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>				
		</div>
	</div>
</body>
</html>